(function () {
    'use strict';

    angular.module('KingAdmin.pages.pdev')
        .controller('InputModalCtrl', InputModalCtrl);

    /** @ngInject */
    function InputModalCtrl($scope, $uibModal, $stateParams, $timeout, $state, $uibModalInstance, nodes, title) {
        $scope.treeData = nodes;
        $scope.treeshow = true;
        $scope.title = title;

        $scope.readyCB = function() {
            console.log(angular.element('#myTreeId').jstree(true).get_selected());
            angular.element('#myTreeId').bind('select_node.jstree', function (event, data) {
                $scope.selectedNode = data.node;
            })
        };

        $scope.basicConfig = {
            core: {
                check_callback: true,
                worker: true
            },
            'types': {
                'default': {
                    'icon': false
                }
            },
            "checkbox": {
                "keep_selected_style": false
            },
            'plugins': ['types', "wholerow"],
            'version': 1
        };

        $scope.ok = function () {
            $uibModalInstance.close($scope.selectedNode);
        };
        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');
        };
    }

})();
